/** Unit test program to test the EventProcessor and Messaging capablities */

// how many generators are started
#define NUM_GENERATORS 10 
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

#include "Master.h"
#include "Generator.h"
#include "DistributedCounter.h"
#include "TwoWayList.cc"

int main(void){
	
  Master master;
  master.ForkAndSpin(); 

  DistributedCounter dCounter(NUM_GENERATORS);
	
  TwoWayList <EventProcessor> myGens;
  for (int i=0; i<NUM_GENERATORS; ++i) {
    Generator newGen(master, dCounter);
    newGen.ForkAndSpin();
    myGens.Insert(newGen);
  }

  master.WaitForProcessorDeath(); 

  int result = NUM_GENERATORS*REPETITIONS*(REPETITIONS+1)/2; 
  cout<<"The correct outcome : "<<result<<endl;
  return 0;
}
